package com.atguigu.controller;


import com.alibaba.dubbo.config.annotation.Reference;
import com.atguigu.entity.Dict;
import com.atguigu.result.Result;
import com.atguigu.service.DictService;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("dict")
public class DictController {
    @Reference
    private DictService dictService;

    @RequestMapping("findListByDictCode/{dictCode}")
    public Result<List<Dict>> findListByDictCode(@PathVariable String dictCode){
        List<Dict> list = dictService.findListByCode(dictCode);
        return Result.ok(list);
    }

    @GetMapping("findListByParentId/{areaId}")
    @ResponseBody
    public Result findListByParentId(@PathVariable Long areaId){
        List<Map<String, Object>> znodes = dictService.findZnodes(areaId);
        return Result.ok(znodes);
    }


}
